home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
cobalts.arc
/
SND2TXT.C
< prev
next >
Wrap
Text File
|
1990-09-03
|
1KB
|
49 lines
/* snd2txt.c by Bill and Erin */
/* converts binary musical files of type .SND */
/* to integer arrays for embedding in C code */
#include <stdio.h>
main(int argc, char *argv[])
{
FILE *fp,*fp2;
char *wordptr;
int frequency,duration,counter=0;
char scratchbuffer[128],writebuffer[128];
if(argc!=2)exit(0);
if((fp=fopen(argv[1],"rb"))==NULL)exit(0);
strcpy(scratchbuffer,argv[1]);
wordptr=strtok(scratchbuffer,".");
sprintf(writebuffer,"%s.TXT",scratchbuffer);
fp2=fopen(writebuffer,"w");
fprintf(fp2,
"/* musical array created from file %s */\n",argv[1]);
fprintf(fp2,
"/* array structure is frequency,duration */\n");
fprintf(fp2,
"int %s[]={\n",scratchbuffer);
while((frequency=getw(fp))!=-1){
duration=fgetc(fp);
fprintf(fp2,"%5d, %2d,",frequency,duration);
counter++;
if(counter==6){
fprintf(fp2,"\n");
counter=0;
}
}
fprintf(fp2,"-1,-1};\n",scratchbuffer);
fclose(fp);
fclose(fp2);
exit(0);
}